package cs575.wido.model;

import cs575.client.GroupEx;
import cs575.client.GroupMember;
import cs575.client.Session;
import cs575.wido.UserSession;
import cs575.wido.WebServiceFactory;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;

import javax.swing.AbstractListModel;

public class MemberListModel extends AbstractListModel implements List {
	private GroupEx group;
	List<GroupMember> members;
	
	cs575.client.WiDo wido;
	Session session;
	
	public MemberListModel() {
		this.wido = WebServiceFactory.getPort();
		this.session = UserSession.getInstance().getSession();
	}

	public GroupEx getGroup() {
		return group;
	}

	public void setGroup(GroupEx group) {
		this.group = group;
		this.members = wido.getGroupMembers(session, group.getGroupId());
		this.fireContentsChanged(this, 0, this.getSize());
	}
	
	@Override
	public Object getElementAt(int arg0) {
		if (members != null) {
			return members.get(arg0).getUser().getUserName();
		}
		else {
			return "";
		}
	}

	@Override
	public int getSize() {
		if (members != null) {
			return members.size();
		}
		else {
			return 0;
		}
	}

	@Override
	public boolean add(Object arg0) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public void add(int arg0, Object arg1) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public boolean addAll(Collection arg0) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean addAll(int arg0, Collection arg1) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public void clear() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public boolean contains(Object arg0) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean containsAll(Collection arg0) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public Object get(int arg0) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public int indexOf(Object arg0) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public boolean isEmpty() {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public Iterator iterator() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public int lastIndexOf(Object arg0) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public ListIterator listIterator() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public ListIterator listIterator(int arg0) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public boolean remove(Object arg0) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public Object remove(int arg0) {
		// TODO Auto-generated method stub
		fireContentsChanged(this, 0, getSize());
		return null;
	}

	@Override
	public boolean removeAll(Collection arg0) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean retainAll(Collection arg0) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public Object set(int arg0, Object arg1) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public int size() {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public List subList(int arg0, int arg1) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Object[] toArray() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Object[] toArray(Object[] arg0) {
		// TODO Auto-generated method stub
		return null;
	}

}
